
import { createApp } from 'vue'
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
import router from './router'
import App from './App.vue'
import request from './utils/request'
import storage from './utils/storage'
import api from './api/index'
import store from './store'

const app = createApp(App)
app.config.globalProperties.$request = request
app.config.globalProperties.$storage = storage
app.config.globalProperties.$api = api

// 自定义指令
app.directive('has', {
  beforeMount: (el, binding) => {
    let userAction = storage.getItem("actionList")
    let value = binding.value
    let hasPermission = userAction.includes(value)
    if (!hasPermission) {
      el.style.display = 'none';
      setTimeout(() => {
        el.parentNode.removeChild(el)
      }, 0)
    }
  }
})
app.use(router)
app.use(ElementPlus)
app.use(store)
app.mount('#app')
